<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<style>
			#msg{margin: 50px;font-size: 50px;color: #FF69B4;}
			.btnstyle{margin: 0px 0px 0px 50px; color: crimson;}
		</style>
	</head>
	<body>
		<div id="msg">0</div>
		
		<div class="btnstyle">
			<button id="btnStart" onclick="start();">开始计时</button>
			<button id="btnStop" onclick="stop();">计时结束</button>
		</div>
	</body>
	
	<script>
		var count = 0;
		var timer;
		var clickstart = 0;
		
		var btnStart = document.getElementById("btnStart");
		var msg = document.getElementById("msg");
		
		function start(){
			if(clickstart %2 != 0){
				timer = setInterval(function(){
					count = count + 1;
					msg.innerText = count;
					},1000);
				clickstart++;					
				btnStart.innerText = "暂停计时";	
			}else{
				clearInterval(timer);
				clickstart = 1;
				btnStart.innerText = "开始计时"
			}
		}
		
		function stop(){
			count = 0;
			msg.innerText = count;
			clearInterval(timer);
			btnStart.innerText = "开始计时";
		}
	</script>
</html>
